﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using DDCMS.EntityFrameworkCore;
using DDCMS.Core.IRepository;
using DDCMS.Domain;
using DDCMS.Domain.Interface;
using DDCMS.Domain.Manager;
using Microsoft.AspNetCore.Identity;


// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace DDCMS.Controllers
{
    public class HomeController : Controller
    {
        private readonly UserManager<User> _userManager;
        private readonly IRepository<Category> _category;
        private readonly ILogger<HomeController> _logger;
        public HomeController(ILogger<HomeController> logger,UserManager<User> userManager, IRepository<Category> category)
        {
            _logger = logger;
            _userManager = userManager;
            _category = category;
         
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            _logger.LogInformation("你访问了首页");
            _logger.LogWarning("警告信息");
            _logger.LogError("错误信息");
            var userinfo = _userManager.GetUserAsync(HttpContext.User).Result;
            //ViewBag.Name = _category.FindSingle(x => x.Id == 1).Name;
            return View(userinfo);
        }
        public IActionResult Create()
        {
            return View();
        }
        public string GetContent()
        {
            return ("hello");
        }
    }
}
